<?php

namespace App\Notifications;

use App\Facades\Sms;
use App\Trip\Notify\Channel\SmsChannel;
use App\Trip\Notify\Sms\Messages\OrderNeedManualHandle;
use Exception;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Support\Facades\Log;

class OrderNeedManualHandleNotify extends Notification
{
    use Queueable;

    /**
     * Create a new notification instance.
     *
     * @return void
     */
    public function __construct(string $order_sn)
    {
        $this->order_sn = $order_sn;
    }

    /**
     * Get the notification's delivery channels.
     *
     * @param mixed $notifiable
     * @return array
     */
    public function via($notifiable)
    {
        return [SmsChannel::class,];
    }


    function toSms($notifiable)
    {
        try {
            $message = new OrderNeedManualHandle($this->order_sn);
            Sms::send(14709986080, $message);
        } catch (Exception $e) {
            Log::error("需人工处理订单,短信发送失败:{$e->getMessage()}");
        }
    }
}
